export class UniTool {
  constructor() {
  }

  static loading(title = '正在加载...', mask = true) {
    uni.showLoading({
      title,
      mask
    })
  }

  static closeLoading() {
    uni.hideLoading()
  }

  static confirm(text,title, options) {
    const {
      confirmButtonText,
      cancelButtonText

    } = options || {}
    return new Promise((resolve, reject) => {
      uni.showModal({
        confirmText: confirmButtonText,
        cancelText: cancelButtonText,
        content:text,
        title,
        success(res) {
          if (res.confirm) {
            resolve()
          } else if (res.cancel) {
            reject()
          }
        },
        fail(){
          reject()
        }
      })
    })
  }
}
